﻿@using Utils
@model PH.Model.Achievements.MarkModel

<div class="GeneralEdit" id="fmMark">
    <ul>
        <li>
            <label>身份证号：</label>
            <b>@Model.StudentNo</b>
        </li>
        <li>
            <label>班级：</label>
            <b>@Model.ClassName</b>
        </li>
        <li>
            <label>姓名：</label>
            <b>@Model.StudentName</b>
        </li>
        <li>
            <label>项目：</label>
            <b>@Model.Subject.SubjectName</b>
        </li>
        <li>
            <label for="txtAchievement">成绩：</label>
            <input type="text" class="k-textbox" id="txtAchievement" name="achievement" required />
            <span class="k-invalid-msg" data-for="achievement"></span>
        </li>
        <li class="editButtons">
            <button id="btnSaveClass" class="k-button"><span class="k-icon k-i-tick"></span><span>确认提交</span></button>
            &nbsp;&nbsp;
            <button class="k-button" onclick="CancelGeneralEdit();"><span class="k-icon k-i-cancel"></span><span>&nbsp;返&nbsp;回</span></button>
        </li>
    </ul>
</div>
<script class="init">
    $("#txtAchievement").val(ShowAchievement("@Model.Achievement.ToString().RemoveLastZero()", "@Model.Subject.Category"));
</script>
<script class="save">
    $(function () {
        var validator = $("#fmMark").kendoValidator().data("kendoValidator");
        $("#btnSaveClass").click(function (e) {
            if (validator.validate()) {
                var values = {
                    id: "@Model.ID",
                    newmark: $("#txtAchievement").val(),
                };

                Whale.Remote.Operation({
                    url: "/Achivevments/Mark/Update",
                    parameters: values,
                    success: function (result) {
                        wndGeneralEdit.close();
                        if ($("#grid_marks").length > 0)
                            $("#grid_marks").data("kendoGrid").dataSource.read();
                        if ($("#grid_dbs").length > 0)
                            $("#grid_dbs").data("kendoGrid").dataSource.read();
                    },
                    error: function (msg) {
                        wndGeneralInformation.content(msg).open();
                    }
                });
            }
            return false;
        });
    });
</script>
